/*
 * @Date: 2020-11-02 15:53:09
 * @LastEditTime: 2020-12-31 15:02:54
 * @FilePath: /show/src/router/index.js
 * @Author: twy
 * @LastEditors: twy
 */
import {createRouter, createWebHistory } from "vue-router";

const routes = [{
  path: '/',
  name: 'app',
  component: () => import('../views/index.vue'),
  children: [
    {
      path: 'home',
      name: 'home',
      component: () => import('../views/home/index.vue')
    },{
      path: 'ourValue',
      name: 'ourValue',
      component: () => import('../views/ourValue/index.vue')
    },{
      path: 'ourTeam',
      name: 'ourTeam',
      component: () => import('../views/ourTeam/index.vue')
    },{
      path: 'ourStrategy',
      name: 'ourStrategy',
      component: () => import('../views/ourStrategy/index.vue')
    }
  ]
}]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
});

router.beforeEach((to,from,next) => {
  console.log(to.path,from);
  if (to.path === "/") {
    next({
      path: '/home'
    })
  } else {
    next()
  }
})

export default router;
